package com.ft.adbix.core.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import com.ft.adbix.utils.AdLogUtils;
import com.ft.adbix.utils.AdTrackerReporter;

public class InteractionLayout extends FrameLayout {
    private int downX = 0;
    private int downSX = 0;
    private int downY = 0;
    private int downSY = 0;
    private int moveX = 0;
    private int moveSX = 0;
    private int moveY = 0;
    private int moveSY = 0;
    private int upX = 0;
    private int upSX = 0;
    private int upY = 0;
    private int upSY = 0;
    private AdTrackerReporter reporter;

    public InteractionLayout(Context context) {
        super(context);
    }

    public InteractionLayout(Context context, AttributeSet var2) {
        super(context, var2);
    }

    public InteractionLayout(Context context, AttributeSet var2, int var3) {
        super(context, var2, var3);
    }

    public void setReporter(AdTrackerReporter reporter) {
        this.reporter = reporter;
    }

    public boolean dispatchTouchEvent(MotionEvent var1) {
        if (var1 != null) {
            switch (var1.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    this.downX = (int) var1.getX();
                    this.downSX = (int) var1.getRawX();
                    this.downY = (int) var1.getY();
                    this.downSY = (int) var1.getRawY();
                    if (reporter != null) {
                        reporter.markDown(downX, downY, downSX, downSY);
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    this.upX = (int) var1.getX();
                    this.upSX = (int) var1.getRawX();
                    this.upY = (int) var1.getY();
                    this.upSY = (int) var1.getRawY();
                    if (reporter != null) {
                        reporter.markUp(downX, downY, downSX, downSY);
                    }
                    AdLogUtils.d("dispatchTouchEvent view coordinate : (" + this.downX + "," + this.downY + "," + this.upX + "," + this.upY + ")");
                    AdLogUtils.d("dispatchTouchEvent screen coordinate : (" + this.downSX + "," + this.downSY + "," + this.upSX + "," + this.upSY + ")");
                    break;
                case MotionEvent.ACTION_MOVE:
                case MotionEvent.ACTION_CANCEL:
                    this.moveX = (int) var1.getX();
                    this.moveSX = (int) var1.getRawX();
                    this.moveY = (int) var1.getY();
                    this.moveSY = (int) var1.getRawY();
            }
        }

        return super.dispatchTouchEvent(var1);
    }

    public int getDownX() {
        return this.downX;
    }

    public int getDownSX() {
        return this.downSX;
    }

    public int getDownY() {
        return this.downY;
    }

    public int getDownSY() {
        return this.downSY;
    }

    public int getUpX() {
        return this.upX;
    }

    public int getUpSX() {
        return this.upSX;
    }

    public int getUpY() {
        return this.upY;
    }

    public int getUpSY() {
        return this.upSY;
    }

    public int getMoveX() {
        return this.moveX;
    }

    public int getMoveSX() {
        return this.moveSX;
    }

    public int getMoveY() {
        return this.moveY;
    }

    public int getMoveSY() {
        return this.moveSY;
    }
}
